using System;
using System.Drawing;
using System.Windows.Forms;



// Image Label, can be used as a fake of transparent labels (unsupported on .NET CE)
public class SolidLabel:Control
{
	private Bitmap	bufferBitmap;
	private Color	c_back;
	private Color	c_text;
	private Font	f_text;
	private SolidBrush b_back;
	private SolidBrush b_text;

	public SolidLabel (Rectangle dimensions, Font f, Color text, Color back):base()
	{
		
		f_text = new Font(f.Name,f.Size,f.Style);
		c_text = new Color();
		c_back = new Color();
		
		this.Bounds = dimensions;
		c_text = text;
		c_back = back;
		b_back = new SolidBrush(c_back);
		b_text = new SolidBrush(c_text);
		bufferBitmap = new Bitmap (this.Bounds.Width, this.Bounds.Height);
	}

	public Color TexteColor
	{
		get {return c_text; }
		set
		{
			c_text = value;
			Invalidate();
		}
	}
	public Color FonsColor
	{
		get {return c_back; }
		set 
		{
			c_back = value;
			Invalidate();
		}
	}
	protected override void OnTextChanged(EventArgs e)
	{
		this.Invalidate();
		base.OnTextChanged (e);
	}

	protected override void OnPaintBackground(PaintEventArgs e)
	{
		Graphics gxOff; //Offscreen graphics

		gxOff = Graphics.FromImage(bufferBitmap);
		gxOff.FillRectangle(b_back, 0, 0, this.Bounds.Width, this.Bounds.Height);

		gxOff.DrawString(this.Text, f_text, b_text, 0, 0);
		
		e.Graphics.DrawImage(bufferBitmap, 0, 0);//copy back to screen
	}
}

 